#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main()
{
    int fd[2];
    int ret = pipe(fd);
    if(-1 == ret) {
        perror("pipe error");
        exit(1);
    }

    pid_t pid = fork();

    if(0 == pid) {
        sleep(3);
        write(fd[1], "Hello", 6);
    }else if(pid > 0) {
        char buf[20] = {0};
        int ans = read(fd[0], buf, sizeof(buf));

        if(ans > 0) {
            write(STDOUT_FILENO, buf, ans);
        }
    }

    return 0;
}

